package com.zfx.service.impl;

import com.zfx.mapper.ISecondarySystemFunctionMessageMapper;
import com.zfx.pojo.SecondarySystemFuncationMessage;
import com.zfx.service.ISecondarySystemFunctionMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @description:
 * @author: zfx
 * @version: 1.0
 * @time: 2020-05-13 20:35
 * <p>
 * 修改历史：
 * 修改日期      修改人员    版本    内容
 * 2020-05-13   zfx       1.0
 */
@Service
public class SecondarySystemFunctionMessageServiceImp implements ISecondarySystemFunctionMessageService {

    @Autowired
    private ISecondarySystemFunctionMessageMapper secondarySystemFunctionMessageMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int update(SecondarySystemFuncationMessage message) {

        SecondarySystemFuncationMessage secondarySystemFuncationMessage = new SecondarySystemFuncationMessage(message.getLevel1SystemId(),message.getTypeId());

        message.setSecondarySystemId(secondarySystemFunctionMessageMapper.selectOne(secondarySystemFuncationMessage).getSecondarySystemId());

        return secondarySystemFunctionMessageMapper.updateByPrimaryKeySelective(message);
    }

    @Transactional(readOnly = true)
    @Override
    public SecondarySystemFuncationMessage selectByLevel1SystemIdAndTypeId(SecondarySystemFuncationMessage secondarySystemFuncationMessage) {
        return secondarySystemFunctionMessageMapper.selectOne(secondarySystemFuncationMessage);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int deleteByTableId(int level1SystemId) {

        SecondarySystemFuncationMessage message = new SecondarySystemFuncationMessage();
        message.setLevel1SystemId(level1SystemId);
        return secondarySystemFunctionMessageMapper.delete(message);
    }

}
